import React, { PureComponent } from 'react';
import { Swiper } from 'antd-mobile'
import "../../styles/index/myswiper.scss"
class MySwiper extends PureComponent {
    constructor() {
        super()
        this.state = {

        }
    }
    render() {
        return (
            <div className='swiper'>
                <Swiper className='swiper' autoplay autoplayInterval={3000} loop>
                    {
                        // 由于首次加载的话,请求还没有发,那么传过来就是一个空值,可能会报错 那么我们就做一次判断
                        this.props.swperlist && //如果存在swperlist
                        this.props.swperlist.length && //length不为0
                        this.props.swperlist.map((item, index) => {//就进行渲染
                            return (
                                <Swiper.Item key={index}>
                                    <div onClick={() => { }} className="swiper-img">
                                        <img src={item.pic} alt="" />
                                    </div>
                                </Swiper.Item>
                            )
                        })
                    }
                </Swiper>
            </div>
        );
    }
}

export default MySwiper;